<template>
	<view class="home">
    <commonHead title="网易云音乐" :isShow="false" bgcolor="#7599e8"></commonHead>
    <scroll-view scroll-y="true" >
      <!-- 登录 -->
      <view class="login">
        <view class="left">
          <text class="iconfont icon-geren2"></text>
          <text>未登录</text>
        </view>
        <view class="right">
          立即登录
        </view>
      </view>
      
      <!-- 搜索框 -->
      <view class="search" @tap="navToSearch">
        <text class="iconfont icon-sousou"></text>
        <input disabled class="search-box" type="text" value="" placeholder="搜索歌曲"/>
      </view>
      <!-- 广告 -->
      <view class="ad">
        <image src="../../static/images/ad.jpg"></image>
      </view>
      
      <!-- 榜单 -->
      <view class="rank">
        <rankingList v-for="(list,index) in lists" :key='index' :rankList='list'></rankingList>
      </view>
      
    </scroll-view>
	</view>
</template>

<script>
  import commonHead from '../../components/common-head/common-head.vue'
  import rankingList from '../../components/rankingList/rankingList.vue'
  import request from '../../common/request.js'
	export default {
		data() {
			return {
        lists:[],
			}
		},
    components:{
      commonHead,rankingList
    },
		onLoad() {
      request('/toplist/detail').then((res)=>{
        this.lists = res.data.list.slice(0,4);
      },(err)=>{
        console.log(err);
      })
		},
		methods: {
      // 跳转到搜索页面
      navToSearch(){
        uni.navigateTo({
          url:'../search/search'
        })
      }
		}
	}
</script>

<style scoped>
  .home scroll-view{
    box-sizing: border-box;
    width: 100%;
    /* 注意使用calc函数时，进行加减算法 符号两边要留有空格才能有效果 */
    height: calc(100vh - 75px);
    padding: 34rpx;
  }
  
  .login{
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64rpx;
    width: 100%;
    font-size: 26rpx;
    margin-bottom: 20rpx;
  }
  .login .left{
    display: flex;
    align-items: center;
    color: #999999;
  }
  .login .left .icon-geren2{
    font-size: 64rpx;
    margin-right: 22rpx;
  }
  .login .right{
    width: 146rpx;
    height: 54rpx;
    line-height: 54rpx;
    text-align: center;
    border-radius: 27rpx;
    border: 1px solid #efefef;
    color: #545454;
  }
  /* 搜索框 */
  .search{
    position: relative;
    color: #c3c3c3;
    margin-bottom: 32rpx;
  }
  .search .icon-sousou{
    position: absolute;
    width: 34rpx;
    top: 50%;
    transform: translateY(-50%);
    left: 28rpx;
  }
  .search-box{
    box-sizing: border-box;
    height: 74rpx;
    width: 100%;
    font-size: 28rpx;
    border-radius: 37rpx;
    background-color: #F7F7F7;
    padding-left: 82rpx;
    color: #333;
  }
  /* 广告分享 */
  .ad{
    width: 100%;
    height: 268rpx;
    background-color: #007AFF;
    border-radius: 8rpx;
    margin-bottom: 20rpx;
  }
  .ad image{
    width: 100%;
    height: 268rpx;
  }
	
</style>
